﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace chat_app.NhibernateLogic.Managers
{
    public class ContentManager
    {

        public static bool SaveItem<T>(T item)
        {

            using (SessionManager sm = CreateSession())
            {
                sm.CurrentSession.Save(item);
            }
            return true;

        }

        public static IList<T> GetAllItems<T>() where T : class
        {
            using (SessionManager sm = CreateSession())
            {
                var criteria = sm.CurrentSession.CreateCriteria<T>().List<T>();
                return criteria;
            }
        }

        public static SessionManager CreateSession()
        {
            return new SessionManager();
        }
    }
}